package com.Demo1;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-12-04
 * Time: 16:56
 */

//线程池
public class Demo4 {
    public static void main(String[] args) {
        //创建一个固定的线程数目的线程池，参数指定线程的个数
        ExecutorService pool = Executors.newFixedThreadPool(10);

        for (int i = 0; i < 100; i++) {
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello threadPool");
                }
            });
        }
    }
}
